<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<script src="../js/vue.js"></script>

<body>
    <div id="app">
        <h1 ref="mark">{{msg}}</h1>
        <h1 v-if="msg1">{{msg1}}</h1>
        <h1 v-if="msg2">{{msg2}}</h1>
        <h1 v-if="msg3">{{msg3}}</h1>
        <button @click="example">test</button>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                msg: 'tianqing',
                msg1: '',
                msg2: '',
                msg3: ''
            },
            methods: {
                example() {
                    // 
                    this.msg = 'houbang';
                    // 没有更改前的DOM  h1
                    this.msg1 = this.$refs.mark.innerHTML;
                    // 在下次DOM更新循环之后延迟回调，在修改数据之后立即使用该方法，可以获取更新后的DOM
                    this.$nextTick(function () {
                        this.msg2 = this.$refs.mark.innerHTML;
                    })
                    this.msg3 = this.$refs.mark.innerHTML
                }
            },
        })
        // 全局方法
        Vue.nextTick(function () {

        })
    </script>
</body>

</html>